﻿using System;
using System.Xml.Linq;
using System.Net;
using System.ComponentModel;
using Net.Chirash.Twitter.TwitterDatabase;

namespace Net.Chirash.Twitter.TwitterClient
{
    public static partial class ParseExtends
    {
        //#region Public Properties

        //#region public long ID { get; set; }
        //private long _ID;
        //public long ID
        //{
        //    get { return _ID; }
        //    set { _ID = value; OnPropertyChanged("ID"); }
        //}
        //#endregion
        //#region public string Name { get; set; }
        //private string _Name;
        //public string Name
        //{
        //    get { return _Name; }
        //    set { _Name = value; OnPropertyChanged("Name"); }
        //}
        //#endregion
        //#region public string FullName { get; set; }
        //private string _FullName;
        //public string FullName
        //{
        //    get { return _FullName; }
        //    set { _FullName = value; OnPropertyChanged("FullName"); }
        //}
        //#endregion
        //#region public string ShortName { get; set; }
        //private string _ShortName;
        //public string ShortName
        //{
        //    get { return _ShortName; }
        //    set { _ShortName = value; OnPropertyChanged("ShortName"); }
        //}
        //#endregion
        //#region public string Description { get; set; }
        //private string _Description;
        //public string Description
        //{
        //    get { return _Description; }
        //    set { _Description = value; OnPropertyChanged("Description"); }
        //}
        //#endregion
        //#region public int SubscriberCount { get; set; }
        //private int _SubscriberCount;
        //public int SubscriberCount
        //{
        //    get { return _SubscriberCount; }
        //    set { _SubscriberCount = value; OnPropertyChanged("SubscriberCount"); }
        //}
        //#endregion
        //#region public int MemberCount { get; set; }
        //private int _MemberCount;
        //public int MemberCount
        //{
        //    get { return _MemberCount; }
        //    set { _MemberCount = value; OnPropertyChanged("MemberCount"); }
        //}
        //#endregion
        //#region public string Uri { get; set; }
        //private string _Uri;
        //public string Uri
        //{
        //    get { return _Uri; }
        //    set { _Uri = value; OnPropertyChanged("Uri"); }
        //}
        //#endregion
        //#region public ListMode Mode { get; set; }
        //private ListMode _Mode;
        //public ListMode Mode
        //{
        //    get { return _Mode; }
        //    set { _Mode = value; OnPropertyChanged("Mode"); }
        //}
        //#endregion
        //#region public User User { get; set; }
        //private User _User;
        //public User User
        //{
        //    get { return _User; }
        //    set { _User = value; OnPropertyChanged("User"); }
        //}
        //#endregion

        //#endregion

        #region Public Static Methods

        public static TwitterList Parse(this TwitterList twList, string xml)
        {
            XElement element = XElement.Parse(xml);
            //var twList = new TwitterList();

            twList.TwitterListID = long.Parse(element.Element("id").Value);
            twList.Name = element.Element("name").Value;
            twList.FullName = element.Element("full_name").Value;
            twList.ShortName = element.Element("slug").Value;
            twList.Description = element.Element("description").Value;
            twList.SubscrierCount = int.Parse(element.Element("subscriber_count").Value);
            twList.MemberCount = int.Parse(element.Element("member_count").Value);
            twList.Uri = element.Element("uri").Value;
            twList.Mode = element.Element("member_count").ToString();
            twList.OwnerUserID = long.Parse(element.Element("user").Element("id").Value);
            twList.OwnerUser = new User().Parse(element.Element("user").ToString());

            return twList;
        }


        #endregion

    }

    public enum ListMode
    {
        @public,
        @private
    }
}
